home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / SetSuspect / Main.C < prev    next >
C/C++ Source or Header  |  1996-10-31  |  5KB  |  212 lines

  1. /* **** HBBS Door Code****************************************************** */
  2.  
  3. /*
  4.   DoorName
  5.   ========
  6.  
  7.     Sets DoorLogOverride when a current users handle matches the a handle in a list
  8.     of suspect users specified in Progdir:Suspect.CFG in the Users_XX settings
  9.  
  10.   Version
  11.   =======
  12.  
  13.     1.0, release 1, 18/06/1996
  14.  
  15.   Options
  16.   =======
  17.  
  18.     N_ND->ActiveDoor->SystemOptions
  19.     -------------------------------
  20.  
  21.     None
  22.  
  23.     Command Line Arguments
  24.     ----------------------
  25.  
  26.     None
  27.  
  28.   ToDo
  29.   ====
  30.  
  31.     Nothing
  32.  
  33.   Config Files
  34.   ============
  35.  
  36.     Progdir:Suspect.CFG
  37.     -------------------
  38.  
  39.       Users_XX=<Handle>    List of handles
  40.       Message=<Message>    A Message to display to the user if they are Suspect
  41.       LogNewUsers=YES|NO   Log All New Users Actions ?
  42.  
  43. */
  44.  
  45. /* **** Includes *********************************************************** */
  46.  
  47. #include <exec/types.h>
  48. #include <exec/memory.h>
  49. #include <dos/dos.h>
  50. #include <clib/exec_protos.h>
  51. #include <clib/dos_protos.h>
  52. #include <clib/alib_protos.h>
  53.  
  54. #include <stdlib.h>
  55. #include <string.h>
  56. #include <stdio.h>
  57. #include <ctype.h>
  58. #include <time.h>
  59.  
  60. #include <HBBS/ANSI_Codes.h>
  61. #include <HBBS/Defines.h>
  62. #include <HBBS/Access.h>
  63. #include <HBBS/types.h>
  64. #include <HBBS/structures.h>
  65. #include <HBBS/hbbscommon_protos.h>
  66. #include <HBBS/hbbscommon_pragmas.h>
  67. #include <HBBS/Hbbsnode_protos.h>
  68. #include <HBBS/Hbbsnode_pragmas.h>
  69. #include <HBBS/release.h>
  70. char *versionstr="$VER: SetSuspect "RELEASE_STR;
  71.  
  72. /* **** Variables ********************************************************** */
  73.  
  74.  
  75. struct Library *HBBSCommonBase  = NULL;
  76. struct Library *HBBSNodeBase    = NULL;
  77.  
  78. struct BBSGlobalData *BBSGlobal = NULL;
  79. struct NodeData *N_ND           = NULL;
  80. int    N_NodeNum                = -1;
  81. char   outstr[1024];
  82.  
  83. long __stack=16*1024; // increse this in 4k incrments if you suffer from
  84.                       // random/suprious crashings after or during the running
  85.                       // of your door.
  86.  
  87. int    gargc;         // these are just copies of main()'s argc and argv..
  88. char   **gargv;
  89.  
  90. /* **** Functions ********************************************************** */
  91.  
  92.  
  93. #ifdef __SASC
  94. int CXBRK(void) { return(0); }
  95. int _CXBRK(void) { return(0); }
  96. void chkabort(void) {}
  97. #endif
  98.  
  99. static VOID cleanup(ULONG num)
  100. {
  101.   if (HBBSNodeBase)
  102.   {
  103.     HBBS_CleanUpDoor();
  104.     CloseLibrary (HBBSNodeBase);
  105.   }
  106.  
  107.   if (HBBSCommonBase)
  108.   {
  109.     HBBS_CleanUpCommon();
  110.     CloseLibrary (HBBSCommonBase);
  111.   }
  112.  
  113.   if (num) printf("Door Error = %d\n",num);
  114.  
  115.   exit(0);
  116. }
  117.  
  118. static VOID init(char *name)
  119. {
  120.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  121.   {
  122.     cleanup(1);
  123.   }
  124.  
  125.   if (!(HBBS_InitCommon()))
  126.   {
  127.     cleanup(2);
  128.   }
  129.  
  130.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  131.   {
  132.     cleanup(3);
  133.   }
  134.  
  135.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  136.   {
  137.     cleanup(4);
  138.   }
  139.   SetProgramName(name);
  140. }
  141.  
  142. /* **** DoorMain *********************************************************** */
  143.  
  144. void DoorMain( void )
  145. {
  146.   struct CfgFileData *CfgFile;
  147.   struct List *Users=NULL;
  148.   struct Node *node;
  149.   V_STRING MsgStr=NULL;
  150.   BOOL Found=FALSE,LogNewUsers=FALSE;
  151.  
  152.   DOOR_WriteText(ANSI_RESET "SetSuspect V1.0 18/June/1996 Hydra/LSD\r\n");
  153.  
  154.   if (CfgFile=HBBS_LoadConfig("Progdir:Suspect.CFG",LCFG_NONE))
  155.   {
  156.     if (HBBS_GetSetting(CfgFile,(void *)&LogNewUsers,VTYPE_BOOL,"LogNewUsers",OPT_SINGLE) && LogNewUsers && N_ND->User.CallData.Status==USER_NEW)
  157.     {
  158.       Found=TRUE;
  159.     }
  160.     else
  161.     if (HBBS_GetSetting(CfgFile,(void *)&Users,VTYPE_STRINGLIST,"User",OPT_MULTI))
  162.     {
  163.       for (node=Users->lh_Head;!Found && node->ln_Succ;node=node->ln_Succ)
  164.       {
  165.         if (stricmp(node->ln_Name,N_ND->User.CallData.Handle)==0)
  166.         {
  167.           Found=TRUE;
  168.         }
  169.       }
  170.       FreeStrList(Users);
  171.     } else DOOR_PausePrompt("Config File Error, Missing Users Item");
  172.  
  173.     if (Found)
  174.     {
  175.       if (HBBS_GetSetting(CfgFile,(void *)&MsgStr,VTYPE_STRING,"Message",OPT_SINGLE))
  176.       {
  177.         N_ND->DoorLogOverride=TRUE;
  178.         DOOR_WriteText(MsgStr);
  179.         DOOR_WriteText("\r\n");
  180.         FreeStr(MsgStr);
  181.       }
  182.     }
  183.     HBBS_FlushConfig(CfgFile);
  184.   }
  185.   else DOOR_PausePrompt("ProgDir:Suspect.CFG Not Found!");
  186.  
  187. }
  188.  
  189. int main(int argc,char **argv)
  190. {
  191.   gargc=argc;
  192.   gargv=argv;
  193.  
  194.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  195.   {
  196.     printf("Invalid/No Paramaters for door!\n");
  197.     exit (20);
  198.   }
  199.   init("SetSuspect");
  200.  
  201.   if (BBSGlobal=HBBS_GimmeBBS())
  202.   {
  203.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  204.     {
  205.       DoorMain();
  206.     }
  207.   }
  208.   cleanup(0);
  209. }
  210.  
  211. /* **** End Of File ******************************************************** */
  212.